package org.jeecg.modules.business.model;

import org.jeecg.modules.business.entity.BusDict;
import org.jeecg.modules.system.entity.SysDepart;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 字典表 存储树结构数据的实体类
 * <p>
 *
 * @Author xq
 * @Since 20230308
 */
public class BusDictTreeModel implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 对应bus_dict_info中的id字段,前端数据树中的key*/
    private String key;

    /** 对应bus_dict_info中的id字段,前端数据树中的value*/
    private String value;

    /** 对应bus_dict_info中的dict_name字段,前端数据树中的title*/
    private String title;


    private boolean isLeaf;
    // 以下所有字段均与bus_dict_info相同

    private String id;

    private String parentId;

    private String tenantId;

    private String hotelId;

    private String dictName;

    private String dictCode;

    private String description;

    private Integer delFlag;

    private String createBy;

    private Date createTime;

    private String updateBy;

    private Date updateTime;
    private Integer type;

    private List<BusDictTreeModel> children = new ArrayList<>();


    /**
     * 将BusDict对象转换成BusDictTreeModel对象
     * @param busDict
     */
    public BusDictTreeModel(BusDict busDict) {
        this.key = busDict.getId();
        this.value = busDict.getId();
        this.title = busDict.getDictName();
        this.id = busDict.getId();
        this.parentId = busDict.getParentId();
        this.tenantId = busDict.getTenantId();
        this.hotelId = busDict.getHotelId();
        this.dictName = busDict.getDictName();
        this.dictCode = busDict.getDictCode();
        this.description = busDict.getDescription();
        this.delFlag = busDict.getDelFlag();
        this.createBy = busDict.getCreateBy();
        this.createTime = busDict.getCreateTime();
        this.updateBy = busDict.getUpdateBy();
        this.updateTime = busDict.getUpdateTime();
        this.type = busDict.getType();
    }

    public boolean getIsLeaf() {
        return isLeaf;
    }

    public void setIsLeaf(boolean isleaf) {
        this.isLeaf = isleaf;
    }

    public String getKey() {
        return key;
    }


    public void setKey(String key) {
        this.key = key;
    }


    public String getValue() {
        return value;
    }


    public void setValue(String value) {
        this.value = value;
    }


    public String getTitle() {
        return title;
    }


    public void setTitle(String title) {
        this.title = title;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public List<BusDictTreeModel> getChildren() {
        return children;
    }

    public void setChildren(List<BusDictTreeModel> children) {
        if (children==null){
            this.isLeaf=true;
        }
        this.children = children;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getHotelId() {
        return hotelId;
    }

    public void setHotelId(String hotelId) {
        this.hotelId = hotelId;
    }

    public String getDictName() {
        return dictName;
    }

    public void setDictName(String dictName) {
        this.dictName = dictName;
    }

    public String getDictCode() {
        return dictCode;
    }

    public void setDictCode(String dictCode) {
        this.dictCode = dictCode;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    /**
     * 重写equals方法
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        BusDictTreeModel model = (BusDictTreeModel) o;
        return Objects.equals(id, model.id) &&
                Objects.equals(parentId, model.parentId) &&
                Objects.equals(tenantId, model.tenantId) &&
                Objects.equals(hotelId, model.hotelId) &&
                Objects.equals(dictName, model.dictName) &&
                Objects.equals(dictCode, model.dictCode) &&
                Objects.equals(description, model.description) &&
                Objects.equals(delFlag, model.delFlag) &&
                Objects.equals(createBy, model.createBy) &&
                Objects.equals(createTime, model.createTime) &&
                Objects.equals(updateBy, model.updateBy) &&
                Objects.equals(updateTime, model.updateTime) &&
                Objects.equals(type, model.type) &&
                Objects.equals(children, model.children);
    }

    /**
     * 重写hashCode方法
     */
    @Override
    public int hashCode() {

        return Objects.hash(id, parentId,tenantId, hotelId, dictName, dictCode,
                description, delFlag, createBy, createTime, updateBy, updateTime,type,
                children);
    }

}
